<?php

error_reporting(E_ALL | E_STRICT);

if (!defined('PHPUnit_MAIN_METHOD')) {
    define('PHPUnit_MAIN_METHOD', 'AllTests::main');
    chdir(dirname(__FILE__));
}

/**
 * Require PHPUnit_Framework_TestSuite and PHPUnit_TextUI_Runner
 */
require_once 'PHPUnit/Framework/TestSuite.php';
require_once 'PHPUnit/TextUI/TestRunner.php';

/**
 * Require test suites
 */
require_once 'PDODB/Test.php';
require_once 'mysql/AllTests.php';

/**
 * The main test suite for PDODB.
 *
 * @package     PDODB
 * @category    Database
 * @author      Michael J. I. Jackson <mjijackson@gmail.com>
 */
class AllTests
{

    public static function main()
    {
        PHPUnit_TextUI_TestRunner::run(self::suite());
    }

    public static function suite()
    {
        $suite = new PHPUnit_Framework_TestSuite('PDODB Test Suite');

        $suite->addTestSuite('PDODB_Test');

        // add the various test suites we want to run
        foreach ($GLOBALS['PDODB_TEST'] as $driver => $params) {
            $all_tests = $driver . '_AllTests';
            if (class_exists($all_tests, false) && !empty($params)) {
                $suite->addTest(call_user_func(array($all_tests, 'suite')));
            }
        }

        return $suite;
    }

}

/**
 * Require database connection parameters so we know which test suites to run
 */
if (is_readable('conf.php')) {
    require_once 'conf.php';
} else {
    require_once 'conf.php.dist';
}

if (PHPUnit_MAIN_METHOD == 'AllTests::main') {
    AllTests::main();
}

?>
